<template>
  <div>
    <load-more :tip="tip" v-if="!isloading"></load-more>
    <div v-if="isloading">
      <group v-if="verify_card == 1">
        <cell title="真实姓名" :value="data.realname"></cell>
        <cell title="身份证号" :value="data.card"></cell>
        <cell title="手持身份证照" value="已认证"></cell>
        <cell title="身份证正面照" value="已认证"></cell>
        <cell title="身份证反面照" value="已认证"></cell>
      </group>
      <group v-if="verify_company == 1">
        <cell title="企业全称" :value="data.name"></cell>
        <cell title="企业简称" :value="data.short_name"></cell>
        <cell title="营业执照注册号" :value="data.license"></cell>
        <cell title="企业业务电话" :value="data.tel"></cell>
        <cell title="开户名称" :value="data.b_name"></cell>
        <cell title="开户行" :value="data.bank_id"></cell>
        <cell title="开户支行" :value="data.bank"></cell>
        <cell title="结算账号" :value="data.num"></cell>
        <cell title="营业执照照片" value="已认证"></cell>
        <cell title="门店照" :value="data.image? '已认证': '无'"></cell>
      </group>
      <div style="padding: 0.4rem;" v-if="verify_company != 1">
        <x-button type="primary" @click.native="toPath" action-type="button">申请成为企业货主</x-button>
      </div>
    </div>
  </div>
</template>
<script>
import { Cell, LoadMore } from 'vux'
import PubHeader from '../../components/PubHeader.vue'
import { checkCard } from '../../libs/fn'
export default{
  components: {
    PubHeader,
    Cell,
    LoadMore
  },
  data() {
   return {
     title: '',
     data: [],
     isloading: false,
     tip: '加载数据中...'
   }
  },
  computed: {
    verify_card() {
      return this.$route.query.verify_card || ''
    },
    verify_company() {
      return this.$route.query.verify_company || ''
    }
  },
  created() {
    const uid = this.$store.state.userInfo.uid
    this.$http.post($config.host + '/api/Identify/showSendInfo', qs.stringify({
      uid,
      client: $config.client_type,
      device: $config.device_type,
      token: this.$store.state.userInfo.token
    })).then((res) => {
      const {code, data, msg} = res.data
      let userInfo = this.$store.state.userInfo
      userInfo.verify_card = data.verify_card
      userInfo.verify_company = data.verify_company
      this.$store.commit('setUserInfo', userInfo)
      if(code == '1') {
        this.isloading = true
        this.data = data
        if(data.card) {
          this.data.card = data.card.substring(0, 6) + '*********' + data.card.substring(15)
        }
        this.title = this.verify_company == 1? '企业认证': '个人认证'
      } else if (code == '3') {
        this.$vux.toast.text($config.loginErrMsg, 'middle')
        this.$router.push({path: '/logout'})
      } else {
        this.tip = msg
        this.$vux.toast.text(msg, 'middle')
      }
    }).catch((err) => {
      this.tip = $config.errMsg
      this.$vux.toast.text($config.errMsg, 'middle')
    })
  },
  methods: {
    toPath() {
      this.$router.push('companyIdentifying')
    }
  }

}
</script>
